package com.winchain.chainbill.bill.biz.discount.rx;

import com.shell.framework.command.ChainBase;
import com.shell.framework.command.CommandContext;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.bill.biz.discount.cmd.BillDctFinQuotaCmd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDctQtSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	@Autowired
	private BillDctFinQuotaCmd billDctFinQuotaCmd;

	public void onApplicationEvent(BillEvent<CbDct> t) {
		CommandContext<Bill<CbDct>> context = new CommandContext();
		context.setSource(t.getBill());
		context.setValue("quotaOptType", t.getStringValue("quotaOptType"));
		ChainBase<Bill<CbDct>> crb = new ChainBase();

		crb.add(this.billDctFinQuotaCmd);
		crb.execute(context);
	}
}
